/**
 * Created by huhai on 17/8/10.
 */
const {Nuxt, Builder} = require('nuxt')
const app = require('express')()
const isProd = (process.argv[2] === 'production')
const port = process.env.PORT || 3000
console.log(process.env.NODE_ENV,"********")
console.log(isProd? "生产环境xxxx":"开发环境xxx")
// 用指定的配置对象实例化 Nuxt.js
let config = require('./nuxt.config.js')
config.dev = false
const nuxt = new Nuxt(config)


// 在开发模式下启用编译构建和热加载
if (config.dev) {
  const builder = new Builder(nuxt)
  builder.build()
}

// 用 Nuxt.js 渲染每个路由
app.use(nuxt.render)


// 服务端监听
app.listen(port, '0.0.0.0')
console.log("-----------------------------------")
console.log('Server listening on localhost:' + port)
